gdk_gl_context_get_debug_enabled
gdk_gl_context_set_forward_compatible
gdk_gl_context_get_forward_compatible
-GdkGLProfile
-gdk_gl_context_set_profile
-gdk_gl_context_get_profile
<SUBSECTION>
GdkGLError
GdkDisplay *display;
GdkWindow *window;
GdkGLContext *shared_context;
- GdkGLProfile profile;
int major;
int minor;
PROP_DISPLAY,
PROP_WINDOW,
- PROP_PROFILE,
PROP_SHARED_CONTEXT,
LAST_PROP
}
break;
- case PROP_PROFILE:
- gdk_gl_context_set_profile (GDK_GL_CONTEXT (gobject), g_value_get_enum (value));
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
g_value_set_object (value, priv->shared_context);
break;
- case PROP_PROFILE:
- g_value_set_enum (value, priv->profile);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
- /**
- * GdkGLContext:profile:
- *
- * The #GdkGLProfile of the context
- *
- * Since: 3.16
- */
- obj_pspecs[PROP_PROFILE] =
- g_param_spec_enum ("profile",
- P_("Profile"),
- P_("The GL profile the context was created for"),
- GDK_TYPE_GL_PROFILE,
- GDK_GL_PROFILE_DEFAULT,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS);
-
/**
* GdkGLContext:shared-context:
*
return priv->window;
}
-/**
- * gdk_gl_context_set_profile:
- * @context: a #GdkGLContext
- * @profile: the profile for the context
- *
- * Sets the profile used when realizing the context.
- *
- * The #GdkGLContext must not be realized or made current prior to calling
- * this function.
- *
- * Since: 3.16
- */
-void
-gdk_gl_context_set_profile (GdkGLContext *context,
- GdkGLProfile profile)
-{
- GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
-
- g_return_if_fail (GDK_IS_GL_CONTEXT (context));
- g_return_if_fail (!priv->realized);
-
- if (priv->profile != profile)
- {
- priv->profile = profile;
-
- g_object_notify_by_pspec (G_OBJECT (context), obj_pspecs[PROP_PROFILE]);
- }
-}
-
-/**
- * gdk_gl_context_get_profile:
- * @context: a #GdkGLContext
- *
- * Retrieves the #GdkGLProfile set using gdk_gl_context_set_profile().
- *
- * Returns: a #GdkGLProfile
- *
- * Since: 3.16
- */
-GdkGLProfile
-gdk_gl_context_get_profile (GdkGLContext *context)
-{
- GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
-
- g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), GDK_GL_PROFILE_DEFAULT);
-
- return priv->profile;
-}
-
/**
* gdk_gl_context_get_shared_context:
* @context: a #GdkGLContext
gboolean compatible);
GDK_AVAILABLE_IN_3_16
gboolean gdk_gl_context_get_forward_compatible (GdkGLContext *context);
-GDK_AVAILABLE_IN_3_16
-void gdk_gl_context_set_profile (GdkGLContext *context,
- GdkGLProfile profile);
-GDK_AVAILABLE_IN_3_16
-GdkGLProfile gdk_gl_context_get_profile (GdkGLContext *context);
GDK_AVAILABLE_IN_3_16
gboolean gdk_gl_context_realize (GdkGLContext *context,
gint y;
};
-/**
- * GdkGLProfile:
- * @GDK_GL_PROFILE_DEFAULT: The default profile.
- * @GDK_GL_PROFILE_3_2_CORE: Use the OpenGL core profile, with
- * a minimum required version of 3.2; this is the default
- * profile.
- *
- * The profile to be used when creating a #GdkGLContext.
- *
- * Since: 3.16
- */
-typedef enum {
- GDK_GL_PROFILE_DEFAULT,
- GDK_GL_PROFILE_3_2_CORE
-} GdkGLProfile;
-
/**
* GdkGLError:
* @GDK_GL_ERROR_NOT_AVAILABLE: OpenGL support is not available
GdkMirGLContext *context_mir = GDK_MIR_GL_CONTEXT (context);
GdkDisplay *display = gdk_gl_context_get_display (context);
GdkGLContext *share = gdk_gl_context_get_shared_context (context);
- GdkGLProfile profile = gdk_gl_context_get_profile (context);
EGLContext ctx;
EGLint context_attribs[N_EGL_ATTRS];
int major, minor, flags;
return FALSE;
}
- /* "default profile" means 3.2 core profile */
- if (profile == GDK_GL_PROFILE_DEFAULT)
- profile = GDK_GL_PROFILE_3_2_CORE;
-
- if (profile != GDK_GL_PROFILE_3_2_CORE)
- {
- g_set_error_literal (error, GDK_GL_ERROR,
- GDK_GL_ERROR_UNSUPPORTED_PROFILE,
- _("Unsupported profile for a GL context"));
- return FALSE;
- }
-
gdk_gl_context_get_required_version (context, &major, &minor);
debug_bit = gdk_gl_context_get_debug_enabled (context);
forward_bit = gdk_gl_context_get_forward_compatible (context);
GdkWaylandGLContext *context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
GdkDisplay *display = gdk_gl_context_get_display (context);
GdkGLContext *share = gdk_gl_context_get_shared_context (context);
- GdkGLProfile profile = gdk_gl_context_get_profile (context);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
EGLContext ctx;
EGLint context_attribs[N_EGL_ATTRS];
gboolean debug_bit, forward_bit;
int i = 0;
- /* default profile means 3.2 core profile */
- if (profile == GDK_GL_PROFILE_DEFAULT)
- profile = GDK_GL_PROFILE_3_2_CORE;
-
- if (profile != GDK_GL_PROFILE_3_2_CORE)
- {
- g_set_error_literal (error, GDK_GL_ERROR,
- GDK_GL_ERROR_UNSUPPORTED_PROFILE,
- _("Unsupported profile for a GL context"));
- return FALSE;
- }
-
gdk_gl_context_get_required_version (context, &major, &minor);
debug_bit = gdk_gl_context_get_debug_enabled (context);
forward_bit = gdk_gl_context_get_forward_compatible (context);
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
- _("3.2 core GL profile is not available on EGL implementation"));
+ _("Core GL is not available on EGL implementation"));
return NULL;
}
static HGLRC
_create_gl_context (HDC hdc,
GdkGLContext *share,
- GdkGLProfile profile,
int flags,
int major,
int minor)
{
/* we still need a legacy WGL context first for all cases */
HGLRC hglrc_base;
+ /* This is the actual WGL context that we want */
+ HGLRC hglrc;
+ GdkWin32GLContext *context_win32;
- /* Create the WGL Core (3.2+) context, the legacy context *is* needed here */
- if (profile == GDK_GL_PROFILE_3_2_CORE)
- {
- /* This is the actual WGL context that we want */
- HGLRC hglrc;
- GdkWin32GLContext *context_win32;
+ gint attribs[] = {
+ WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
+ WGL_CONTEXT_MAJOR_VERSION_ARB, major,
+ WGL_CONTEXT_MINOR_VERSION_ARB, minor,
+ WGL_CONTEXT_FLAGS_ARB, flags,
+ 0
+ };
- gint attribs[] = {
- WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
- WGL_CONTEXT_MAJOR_VERSION_ARB, major,
- WGL_CONTEXT_MINOR_VERSION_ARB, minor,
- WGL_CONTEXT_FLAGS_ARB, flags,
- 0
- };
+ hglrc_base = wglCreateContext (hdc);
- hglrc_base = wglCreateContext (hdc);
+ if (!wglMakeCurrent (hdc, hglrc_base))
+ return NULL;
- if (!wglMakeCurrent (hdc, hglrc_base))
- return NULL;
+ if (share != NULL)
+ context_win32 = GDK_WIN32_GL_CONTEXT (share);
- if (share != NULL)
- context_win32 = GDK_WIN32_GL_CONTEXT (share);
+ hglrc = wglCreateContextAttribsARB (hdc,
+ share != NULL ? context_win32->hglrc : NULL,
+ attribs);
- hglrc = wglCreateContextAttribsARB (hdc,
- share != NULL ? context_win32->hglrc : NULL,
- attribs);
+ wglMakeCurrent (NULL, NULL);
+ wglDeleteContext (hglrc_base);
- wglMakeCurrent (NULL, NULL);
- wglDeleteContext (hglrc_base);
- return hglrc;
- }
- else
- /* Should not get here anyways, for now */
- return NULL;
+ return hglrc;
}
static gboolean
GError **error)
{
GdkGLContext *share = gdk_gl_context_get_shared_context (context);
- GdkGLProfile profile = gdk_gl_context_get_profile (context);
GdkWin32GLContext *context_win32 = GDK_WIN32_GL_CONTEXT (context);
/* These are the real WGL context items that we will want to use later */
HGLRC hglrc;
gint pixel_format;
+ gboolean debug_bit, compat_bit;
if (!_set_pixformat_for_hdc (context_win32->gl_hdc,
&pixel_format,
return FALSE;
}
- if (profile == GDK_GL_PROFILE_DEFAULT)
- profile = GDK_GL_PROFILE_3_2_CORE;
-
- if (profile == GDK_GL_PROFILE_3_2_CORE)
- {
- gboolean debug_bit, compat_bit;
-
- /* request flags and specific versions for core (3.2+) WGL context */
- gint flags = 0;
- gint glver_major = 0;
- gint glver_minor = 0;
-
- gdk_gl_context_get_required_version (context, &glver_major, &glver_minor);
- debug_bit = gdk_gl_context_get_debug_enabled (context);
- compat_bit = gdk_gl_context_get_forward_compatible (context);
- if (debug_bit)
- flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
- if (compat_bit)
- flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
+ /* request flags and specific versions for core (3.2+) WGL context */
+ gint flags = 0;
+ gint glver_major = 0;
+ gint glver_minor = 0;
- GDK_NOTE (OPENGL,
- g_print ("Creating core WGL context (version:%d.%d, debug:%s, forward:%s)\n",
- major, minor,
- debug_bit ? "yes" : "no",
- compat_bit ? "yes" : "no"));
-
- hglrc = _create_gl_context (context_win32->gl_hdc,
- share,
- profile,
- flags,
- glver_major,
- glver_minor);
- }
- else
- {
- g_set_error_literal (error,
- GDK_GL_ERROR,
- GDK_GL_ERROR_UNSUPPORTED_PROFILE,
- _("Unsupported profile for a GL context"));
+ gdk_gl_context_get_required_version (context, &glver_major, &glver_minor);
+ debug_bit = gdk_gl_context_get_debug_enabled (context);
+ compat_bit = gdk_gl_context_get_forward_compatible (context);
- return FALSE;
- }
+ if (debug_bit)
+ flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
+ if (compat_bit)
+ flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
+ GDK_NOTE (OPENGL,
+ g_print ("Creating core WGL context (version:%d.%d, debug:%s, forward:%s)\n",
+ major, minor,
+ debug_bit ? "yes" : "no",
+ compat_bit ? "yes" : "no"));
+
+ hglrc = _create_gl_context (context_win32->gl_hdc,
+ share,
+ flags,
+ glver_major,
+ glver_minor);
if (hglrc == NULL)
{
g_set_error_literal (error, GDK_GL_ERROR,
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
_("The WGL_ARB_create_context extension "
- "needed to create 3.2 core profiles is not "
+ "needed to create core profiles is not "
"available"));
return NULL;
}
XVisualInfo *xvisinfo;
Display *dpy;
DrawableInfo *info;
- GdkGLProfile profile;
GdkGLContext *share;
GdkWindow *window;
+ gboolean debug_bit, compat_bit;
+ int major, minor, flags;
window = gdk_gl_context_get_window (context);
display = gdk_window_get_display (window);
dpy = gdk_x11_display_get_xdisplay (display);
context_x11 = GDK_X11_GL_CONTEXT (context);
- profile = gdk_gl_context_get_profile (context);
share = gdk_gl_context_get_shared_context (context);
- /* default means 3.2 core profile */
- if (profile == GDK_GL_PROFILE_DEFAULT)
- profile = GDK_GL_PROFILE_3_2_CORE;
+ gdk_gl_context_get_required_version (context, &major, &minor);
+ debug_bit = gdk_gl_context_get_debug_enabled (context);
+ compat_bit = gdk_gl_context_get_forward_compatible (context);
- /* we check for the presence of the GLX_ARB_create_context_profile
- * extension before checking for a GLXFBConfig when creating the
- * GdkX11GLContext instance in gdk_x11_window_create_gl_context().
- */
- if (profile == GDK_GL_PROFILE_3_2_CORE)
- {
- gboolean debug_bit, compat_bit;
- int major, minor, flags;
-
- gdk_gl_context_get_required_version (context, &major, &minor);
- debug_bit = gdk_gl_context_get_debug_enabled (context);
- compat_bit = gdk_gl_context_get_forward_compatible (context);
-
- flags = 0;
- if (debug_bit)
- flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
- if (compat_bit)
- flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
-
- GDK_NOTE (OPENGL,
- g_print ("Creating core GLX context (version:%d.%d, debug:%s, forward:%s)\n",
- major, minor,
- debug_bit ? "yes" : "no",
- compat_bit ? "yes" : "no"));
-
- context_x11->glx_context = create_gl3_context (display,
- context_x11->glx_config,
- share,
- flags, major, minor);
- }
- else
- {
- g_set_error_literal (error, GDK_GL_ERROR,
- GDK_GL_ERROR_UNSUPPORTED_PROFILE,
- _("Unsupported profile for a GL context"));
- return FALSE;
- }
+ flags = 0;
+ if (debug_bit)
+ flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
+ if (compat_bit)
+ flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
+ GDK_NOTE (OPENGL,
+ g_print ("Creating core GLX context (version:%d.%d, debug:%s, forward:%s)\n",
+ major, minor,
+ debug_bit ? "yes" : "no",
+ compat_bit ? "yes" : "no"));
+
+ context_x11->glx_context = create_gl3_context (display,
+ context_x11->glx_config,
+ share,
+ flags, major, minor);
if (context_x11->glx_context == NULL)
{
g_set_error_literal (error, GDK_GL_ERROR,
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
_("The GLX_ARB_create_context_profile extension "
- "needed to create 3.2 core profiles is not "
- "available"));
+ "needed to create core profiles is not available"));
return NULL;
}
{
GdkGLContext parent_instance;
- GdkGLProfile profile;
GLXContext glx_context;
GLXFBConfig glx_config;
GLXDrawable drawable;
*/
typedef struct {
- GdkGLProfile profile;
GdkGLContext *context;
GdkWindow *event_window;
GError *error;
PROP_0,
PROP_CONTEXT,
- PROP_PROFILE,
PROP_HAS_ALPHA,
PROP_HAS_DEPTH_BUFFER,
PROP_HAS_STENCIL_BUFFER,
gtk_gl_area_set_has_stencil_buffer (self, g_value_get_boolean (value));
break;
- case PROP_PROFILE:
- gtk_gl_area_set_profile (self, g_value_get_enum (value));
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
g_value_set_object (value, priv->context);
break;
- case PROP_PROFILE:
- g_value_set_enum (value, priv->profile);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
gdk_gl_context_set_required_version (context,
priv->required_gl_version / 10,
priv->required_gl_version % 10);
- gdk_gl_context_set_profile (context, priv->profile);
gdk_gl_context_realize (context, &error);
if (priv->error != NULL)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
- /**
- * GdkGLArea:profile:
- *
- * The #GdkGLProfile to use to create the GL context for the area.
- *
- * Since: 3.16
- */
- obj_props[PROP_PROFILE] =
- g_param_spec_enum ("profile",
- P_("Profile"),
- P_("The GL profile to use for the GL context"),
- GDK_TYPE_GL_PROFILE,
- GDK_GL_PROFILE_DEFAULT,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_EXPLICIT_NOTIFY |
- G_PARAM_STATIC_STRINGS);
-
/**
* GtkGLArea:auto-render:
*
* realized, and allows you to override how the GL context is
* created. This is useful when you want to reuse an existing GL
* context, or if you want to try creating different kinds of GL
- * profiles.
+ * options.
*
* If context creation fails then the signal handler can use
* gtk_gl_area_set_error() to register a more detailed error
gtk_widget_set_has_window (GTK_WIDGET (area), FALSE);
gtk_widget_set_app_paintable (GTK_WIDGET (area), TRUE);
- priv->profile = GDK_GL_PROFILE_DEFAULT;
priv->auto_render = TRUE;
priv->needs_render = TRUE;
priv->required_gl_version = 0;
*minor = priv->required_gl_version % 10;
}
-/**
- * gtk_gl_area_get_profile:
- * @area: a #GtkGLArea
- *
- * Returns the profile that will be used to create the GL context for the area.
- *
- * Returns: a #GdkGLProfile
- *
- * Since: 3.16
- */
-GdkGLProfile
-gtk_gl_area_get_profile (GtkGLArea *area)
-{
- GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
-
- g_return_val_if_fail (GTK_IS_GL_AREA (area), FALSE);
-
- return priv->profile;
-}
-
-/**
- * gtk_gl_area_set_profile:
- * @area: a #GtkGLArea
- * @profile: a #GdkGLProfile
- *
- * Sets the profile type to be used when creating the context for the widget.
- *
- * This function must be called before the area has been realized.
- *
- * Since: 3.16
- */
-void
-gtk_gl_area_set_profile (GtkGLArea *area,
- GdkGLProfile profile)
-{
- GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
-
- g_return_if_fail (GTK_IS_GL_AREA (area));
- g_return_if_fail (!gtk_widget_get_realized (GTK_WIDGET (area)));
-
- if (priv->profile != profile)
- {
- priv->profile = profile;
-
- g_object_notify (G_OBJECT (area), "profile");
- }
-}
-
/**
* gtk_gl_area_get_has_alpha:
* @area: a #GtkGLArea
int *major,
int *minor);
GDK_AVAILABLE_IN_3_16
-GdkGLProfile gtk_gl_area_get_profile (GtkGLArea *area);
-GDK_AVAILABLE_IN_3_16
-void gtk_gl_area_set_profile (GtkGLArea *area,
- GdkGLProfile profile);
-GDK_AVAILABLE_IN_3_16
gboolean gtk_gl_area_get_has_alpha (GtkGLArea *area);
GDK_AVAILABLE_IN_3_16
void gtk_gl_area_set_has_alpha (GtkGLArea *area,